load("@fbcode_macros//build_defs/lib:rust_oss.bzl", "rust_oss")
load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")
load("@fbsource//tools/build_defs:rust_unittest.bzl", "rust_unittest")

oncall("scm_server_infra")

rust_library(
    name = "commit_cloud",
    srcs = glob([
        "src/**/*.rs",
        "schemas/*.sql",
    ]),
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-trait",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:serde_json",
        "//common/rust/shed/cloned:cloned",
        "//common/rust/shed/facet:facet",
        "//common/rust/shed/justknobs_stub:justknobs",
        "//common/rust/shed/sql:sql",
        "//eden/mononoke/bonsai_git_mapping:bonsai_git_mapping",
        "//eden/mononoke/bonsai_hg_mapping:bonsai_hg_mapping",
        "//eden/mononoke/commit_cloud/helpers:commit_cloud_helpers",
        "//eden/mononoke/commit_cloud/types:commit_cloud_types",
        "//eden/mononoke/common/rust/sql_ext:sql_ext",
        "//eden/mononoke/common/sql_construct:sql_construct",
        "//eden/mononoke/derived_data:changeset_info",
        "//eden/mononoke/facebook/commit_cloud:commit_cloud_intern_utils",
        "//eden/mononoke/mercurial:mercurial_types",
        "//eden/mononoke/metaconfig:metaconfig_types",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/permission_checker:permission_checker",
        "//eden/mononoke/repo_attributes/repo_derived_data:repo_derived_data",
        "//eden/mononoke/server/context:context",
    ] + ([] if rust_oss.is_oss_build() else [
        "//common/rust/shed/futures_stats:futures_stats",
    ]),
)

rust_unittest(
    name = "dbcommitcloud-test",
    srcs = glob(["tests/**/*.rs"]),
    deps = [
        "fbsource//third-party/rust:anyhow",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/fbinit:fbinit-tokio",
        "//eden/mononoke/commit_cloud:commit_cloud",
        "//eden/mononoke/commit_cloud/types:commit_cloud_types",
        "//eden/mononoke/common/sql_construct:sql_construct",
        "//eden/mononoke/mercurial:mercurial_types",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/server/context:context",
    ],
)
